/**
 * Created by Administrator on 2017\9\21 0021.
 */
//确认
function savesuccess(id,hh) {
    console.log('workadmin');
    var work_order_id = $("input[name='workOrderStatus"+id+"']").val();
    var work_order_status = $("#_orderStatus"+work_order_id+" option:selected").val();
    var remarks = $("#remarks"+work_order_id).val();
    var srcs = "/admin/workorder/index";
    // if (hh == 5) {  // 回收站
    //     var srcs = "/admin/workorder/recycle";
    // }
    // if (hh == 1) { // 续费
    //     var srcs = "/admin/workorder/renew";
    // }
    // if (hh == 2) { // 换芯
    //     var srcs = "/admin/workorder/core";
    // }
   

    $.getJSON("/admin/workorder/status",{remarks:remarks,work_order_status:work_order_status,work_order_id:work_order_id},function(data){

           if (data.status == 0) {
               layer.msg(data.message, {time: 1000,icon: 2});
           }else{
               layer.msg(data.message, {time: 1000,icon: 1});
                $("#mainFrame").attr("src",srcs)
           }
    });

	$(".layui-layer-shade").remove();
	$(".layui-layer").remove();

}
 //保存备注
    function saveRemarks(id){
        console.log('workamdin');
        var add_remarks = $("#add_remarks").val();
        if (add_remarks == '') {
            layer.msg('备注不能为空', {time: 1000,icon: 0});
            return false;
        }
        $.getJSON("/admin/workorder/addRemarks", {
            remarks: add_remarks,
            work_order_id: id
        }, function(data) {
            if(data.status == 0) {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 2
                });
            } else {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 1
                });
               // $("#mainFrame").attr("src", "/admin/workorder/index")
               setTimeout(function(){
                    $(".layui-layer-shade").remove();
                    $(".layui-layer").remove();
                },2000)};
              
        });
    }
    //保存备注
    function saveVisit(id){
        var remarks = $("#visit_remarks").val();
        var visit_status = $("#_visitStatus"+id+" option:selected").val();
        $.getJSON("/admin/workorder/returnVisit", {
            remarks: remarks,
            visit_status:visit_status,
            work_order_id: id
        }, function(data) {
            if(data.code == 1) {
                 parent.layer.msg(data.msg, {
                    time: 1000,
                    icon: 1
                });
               $("#mainFrame").attr("src", "/admin/workorder/index")
               setTimeout(function(){
                    $(".layui-layer-shade").remove();
                    $(".layui-layer").remove();
                },2000)
            }else {
                 parent.layer.msg(data.msg, {
                    time: 1000,
                    icon: 2
                });
            }
        });
    }
//取消
function layuihide() {
	$(".layui-layer").remove();
	$(".layui-layer-shade").remove();
}
//查看所有小弹窗
function lookup(obj){
     var txt = $(obj).text()
     parent.layer.tips(txt, $(obj),{tips:[2,"#337ab7"]});
 }
// 实名审核
function realnamesave (id,user_id) {
    var status = $("#_orderStatus"+id+" option:selected").val();
    var remarks = $("#remarks"+id).val();
    var srcs = "/admin/realname/index";
    $.getJSON("/admin/realname/status",{remarks:remarks,status:status,auth_id:id,user_id:user_id},function(data){

        if (data.status == 0) {
            layer.msg(data.message, {time: 1000,icon: 2});
        }else{
            layer.msg(data.message, {time: 1000,icon: 1});
            $("#mainFrame").attr("src",srcs)
        }
    });

    $(".layui-layer-shade").remove();
    $(".layui-layer").remove();
}

// 投诉处理
function complaint (id) {
    var status = $("#_orderStatus"+id+" option:selected").val();
    var remarks = $("#remarks"+id).val();
    var srcs = "/admin/complaint/index";
    $.getJSON("/admin/complaint/status",{ remarks: remarks, status: status, complaint_id: id },function(data){
        if (data.status == 0) {
            layer.msg(data.message, {time: 1000,icon: 2});
        }else{
            layer.msg(data.message, {time: 1000,icon: 1});
            $("#mainFrame").attr("src",srcs)
        }
    });

    $(".layui-layer-shade").remove();
    $(".layui-layer").remove();
}
function jumpcustome() {
	$("#mainFrame").attr('src', '/admin/Customerinfo/add' + '#equipment');
	cancelmodel();
}

// 指派工程人员弹窗，新增工程人员按钮
function engineeradd() {
    $("#mainFrame").attr('src', '/admin/Engineer/add' + '#equipment');
    cancelmodel();
}